var mysql = require('mysql');

/**************************************************************************************************************
 * use mysql with pool
 **************************************************************************************************************/
var pool = mysql.createPool({
    host: 'localhost',
    database: "AuthCenter",
    user: 'root',
    password: 'root',
    connectTimeout: 10000, // default 10000
    dateStrings: true, // default false
    connectionLimit: 100 // default 10
});

var mysqlWrap    = {};

//获取连接
mysqlWrap.getConnection = function(callback){
    pool.getConnection(function(err, connection) {
        if (err) {
            callback(null);
            return;
        }
        callback(connection);
    });
}
module.exports = mysqlWrap;